import Vue from "vue";
import Vuex from "vuex";
import getters from "./getters";
import app from "./modules/app";
import settings from "./modules/settings";
import user from "./modules/user";
import admin from "./modules/admin";
import goods from "./modules/goods";
import orderGoods from "./modules/orderGoods";
import orderServices from "./modules/orderServices";

Vue.use(Vuex);

const store = new Vuex.Store({
  modules: {
    app,
    settings,
    user,
    admin,
    goods,
    orderGoods,
    orderServices
  },
  getters,
  state: {
    userInfo: {}, // 存储用户的信息
    isAddRouter: false, // 是否动态的添加过路由
    asyncRoutes: [] // 动态的路由表
  },
  mutations: {
    // 公共方法
    update(state, obj) {
      let { name, value } = obj;
      state[name] = value;
    }
  }
});

export default store;
